home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / Goodies / Animation Libraries / GENetRelease2ƒ / GEDemo / Pogo.c < prev    next >
Text File  |  1994-06-24  |  2KB  |  84 lines

  1. /*
  2.     Pogo.c
  3.     
  4.     Boy on pogo stick for Graphic Elements demo
  5.     
  6.     Copyright 1993 by Al Evans. All rights reserved.
  7.     
  8.     11/10/93
  9. */
  10.  
  11. #include "Pogo.h"
  12. #include "Paths.h"
  13.  
  14. #undef COMMERCIALRELEASE
  15.  
  16. static PathEntry    pogoPathRec[11] =    {
  17.                                            {absMotionCmd, 3, 0, -22},
  18.                                          {repeatCmd, 10, 0, 0},
  19.                                          {relMotionCmd, 0, 0, 2},
  20.                                          {relMotionCmd, 4, 0, 0},
  21.                                          {repeatCmd, 10, 0, 0},
  22.                                          {relMotionCmd, 0, 0, 2},
  23.                                          {absMotionCmd, 5, 0, 0},
  24.                                          {absMotionCmd, 6, 0, 0},
  25.                                          {absMotionCmd, 1, 0, 0},
  26.                                          {absMotionCmd, 2, 0, 0},
  27.                                          {resetCmd, 0, 0, 0}
  28.                                          };
  29.  
  30. #ifdef COMMERCIALRELEASE                                         
  31. pascal void DisposePogo(GEWorldPtr world, GrafElPtr pogo)
  32. {
  33.     if (pogo->drawData)
  34.         DisposPtr(pogo->drawData);
  35.     if (pogo->changeData)
  36.         DisposPtr(pogo->changeData);
  37. }
  38. #endif
  39.  
  40. Boolean LoadPogoScene(GEWorldPtr world)
  41. {
  42.     GrafElPtr        thisElement;
  43.     PathRecPtr        pogoPath;
  44.  
  45.     //Get walking figure
  46.     thisElement = NewAnimatedGraphic(world, pogoID, pogoPlane, rPogoPic,
  47.                                 transparent, pogoLeft, pogoTop, 6);
  48.     if (thisElement == nil) return false;
  49.  
  50. #ifdef COMMERCIALRELEASE    
  51.     //Use masked drawing
  52.     thisElement->drawData = MakeMask(&((GrafPtr) thisElement->graphWorld)->portBits);
  53.     thisElement->copyMode = srcCopy;
  54.     
  55.     //Be sure to dispose mask & path
  56.     SetCleanupProc(world, pogoID, DisposePogo);
  57. #endif
  58.     
  59.                                 
  60.     //Init path
  61.     pogoPath = (PathRecPtr) NewPtrClear(sizeof(PathRec));
  62.     InitPath(pogoPath);
  63.     pogoPath->path = pogoPathRec;
  64.     
  65.     //Init animation
  66.     SetAutoChange(world, pogoID, DoPogoStick, (Ptr) pogoPath, 67);
  67.     
  68.     thisElement->collisionPlane = 600;
  69.     
  70.     return true;
  71. }
  72.  
  73. pascal void DoPogoStick(GEWorldPtr world, GrafElPtr pogo)
  74. {
  75.     PathRecPtr pogoPath;
  76.     
  77.     pogoPath = (PathRecPtr) pogo->changeData;
  78.     GetNextStep(pogoPath);
  79.     if (pogoPath->currFrame)
  80.         SetFrame(world, pogo->objectID, pogoPath->currFrame);
  81.     if (pogoPath->currYMove)
  82.         MoveElement(world, pogo->objectID, 0, pogoPath->currYMove);
  83.     
  84. }